package company.Ali;

import java.util.Scanner;

/**
 * 阿里校招编程题1
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-07 19:34
 */
public class A01 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = scanner.nextInt();
            }

            System.out.println(helper(array, n));
        }
    }

    /**
     *
     * @param array
     * @param n
     * @return
     */
    public static int helper(int[] array,int n){
        int res = 0;
        if (array == null || array.length <=3) return res;
        for (int i = 3; i <= n; i++) {
            if (n % i ==0){
                for (int j = 1; j <= n/i; j++) {
                    if (verity(array,j,i)) {
                        res++;
                    }
                }
            }
        }
        
        return res;
    }
    
    public static boolean verity(int[] array,int gap,int len){

        int[] n = new int[len];
        int[] visit = new int[array.length];
        for (int i = 0; i < array.length ; i++) {
            if (visit[i] == 1) continue;
            for (int j = i,k = 0; k < len; j += gap,k++) {
                n[k] = array[j];
                visit[j] = 1;
            }
            if (!check(n,len)) return false;
        }

        return true;
    }

    public static boolean check(int[] n,int len){
        //判断等差
        boolean f1 = true,f2 =true;
        for (int i = 1; i < len-1; i++) {
            if ((n[i] - n[i-1]) != (n[i+1] - n[i])){
                f1 = false;
                break;
            }
        }

        //判断等比
        for (int i = 1; i < len-1; i++) {
            if ((n[i] / n[i-1]) != (n[i+1] / n[i]) || (n[i] % n[i-1] != n[i+1] % n[i]) ){
                f2 = false;
                break;
            }
        }

        return f1 || f2;
    }

}
